package model;

import java.util.List;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.exception.ActiveRecordException;

@Table(name = "news")
// 班级类型
public class News extends ActiveRecordBase {
	@Id
	private int id;
	@Column
	private String title;
	@Column
	private String time;
	@Column
	private int authorId;
	// 页面显示用
	private String author;
	@Column
	private String content;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}


	public int getAuthorId() {
		return authorId;
	}

	public void setAuthorId(int authorId) {
		this.authorId = authorId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	// 生成新闻列表
	public List<News> getNews() throws Exception {
		List<News> l_news = findBySql(News.class,
					"select * from news order by time desc",
					new Object[]{});
		return l_news;
	}
	//获得具体的新闻
	public News getNewsById(String id) throws ActiveRecordException {
		News news = findFirst(News.class, "id=?",
				new Object[]{id});
		return news;
	}
}
